package com.goldman.aplt.base.exception;

import java.text.MessageFormat;

/**
 * 应用平台异常处理
 */
public class BankBusiException extends RuntimeException {
    private String code;
    private String msg;
    private BaseErrorCode errorCode;
    private Object[] args;
    private String error;

    public BankBusiException(BaseErrorCode errorCode) {
        super(errorCode.getMsg());
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
        this.error = errorCode.getMsg();
    }

    public BankBusiException(BaseErrorCode errorCode, Object... args) {
        super(MessageFormat.format(errorCode.getMsg(), args));
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.error = this.getMessage();
        this.msg = this.getMessage();
        this.args = args;
    }

    public BankBusiException(BaseErrorCode errorCode, String error) {
        super(errorCode.getMsg());
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
        this.error = error;

    }

    public BankBusiException(BaseErrorCode errorCode, String error, String msg) {
        super(msg);
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.msg = msg;
        this.error = error;

    }


    public BankBusiException(BaseErrorCode errorCode, String error, Object... args) {
        super(MessageFormat.format(errorCode.getMsg(), args));
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.error = error;
        this.msg = this.getMessage();
        this.args = args;
    }

    public BankBusiException(BaseErrorCode errorCode, Throwable cause) {
        super(cause);
        this.errorCode = errorCode;
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }

    public BankBusiException(BaseErrorCode errorCode, Throwable cause, Object... args) {
        super(cause);
        this.code = errorCode.getCode();
        this.msg = MessageFormat.format(errorCode.getMsg(), args);
    }

    public BankBusiException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public BaseErrorCode getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(BaseErrorCode errorCode) {
        this.errorCode = errorCode;
    }

    public Object[] getArgs() {
        return args;
    }

    public void setArgs(Object[] args) {
        this.args = args;
    }


    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }
}
